home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7302 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: watnews.watson.ibm.com!ncohen
  2. From: ncohen@watson.ibm.com (Norman H. Cohen)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. Date: 22 Feb 1996 14:32:10 GMT
  6. Organization: IBM T.J. Watson Research Center
  7. Distribution: world
  8. Message-ID: <4ghupa$10f5@watnews1.watson.ibm.com>
  9. References: <4gbq7q$g08@qualcomm.com> <4gdidj$10f5@watnews1.watson.ibm.com> <4gg6da$8jk@wdl1.wdl.loral.com>
  10. Reply-To: ncohen@watson.ibm.com
  11. NNTP-Posting-Host: rios8.watson.ibm.com
  12.  
  13. In article <4gg6da$8jk@wdl1.wdl.loral.com>, mab@dst17.wdl.loral.com
  14. (Mark A Biggar) writes: 
  15.  
  16. |> Given the above example, is the following code legal, I have been unable to
  17. |> determine if it is from the RM95: 
  18. |>
  19. |> with Parent.Child;
  20. |> package My_Package is
  21. |>
  22. |>   A: Parent.Child.Auxiliary_Type;  -- or must I say A: Parent.Auxiliary_Type
  23. |>
  24. |> end My_Package;
  25.  
  26. No, it is illegal.  The effect of the with clause is as if you were
  27. compiling My_Package in the following context: 
  28.  
  29.    package Parent is
  30.       ...
  31.       type Auxiliary_Type is ...;
  32.       ...
  33.       package Child is
  34.          ...
  35.       end Child;
  36.    end Parent;
  37.  
  38.    package My_Package is
  39.       ...
  40.    end My_Package;
  41.  
  42. so you must say Parent.Auxiliary_Type.
  43.  
  44. |> If the above is illegal then it presents a problem if I have a library
  45. |> level renaming of Parent.Child, like so: 
  46. |>
  47. |> package My_Child renames Parent.Child;
  48. |>
  49. |> with My_Child;
  50. |> package Foo is
  51. |>
  52. |>   A: My_Child.Auxiliary_Type; -- LEGAL?
  53. |>
  54. |> end Foo;
  55.  
  56. Not legal, and there is no way to name Auxiliary_Type inside Foo, because
  57. Parent is not visible there.  (AARM 10.1.2(9.b))  If you want to name an
  58. entity exported by Parent (and not reexported), the name Parent must
  59. appear in the with clause (possibly as a prefix).  This makes you write a
  60. slightly longer with clause, but it is a very helpful property for
  61. program readers trying to determine the origin of an entity named in Foo.
  62.  
  63. |> If this type of naming is legal then there is a simple emulation of
  64. |> Norman's multi-part package proposal using child packages and a library
  65. |> level rename.
  66.  
  67. It's not, but in any event my proposal allows a public part of a package
  68. to refer to entities declared in an earlier private part of the package,
  69. while still allowing the public part to be mentioned anywhere in a with
  70. clause.  You can't do that with public and private children, because of
  71. restrictions on where you can name private children in a with clause.
  72.  
  73. --
  74. Norman H. Cohen    ncohen@watson.ibm.com
  75.